home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / DJBSN116.ARJ / BISON.SIM < prev    next >
Text File  |  1992-03-29  |  15KB  |  626 lines

  1. /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
  2. #line 3 "bison.simple"
  3.  
  4. /* Skeleton output parser for bison,
  5.    Copyright (C) 1984, 1989, 1990 Bob Corbett and Richard Stallman
  6.  
  7.    This program is free software; you can redistribute it and/or modify
  8.    it under the terms of the GNU General Public License as published by
  9.    the Free Software Foundation; either version 1, or (at your option)
  10.    any later version.
  11.  
  12.    This program is distributed in the hope that it will be useful,
  13.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.    GNU General Public License for more details.
  16.  
  17.    You should have received a copy of the GNU General Public License
  18.    along with this program; if not, write to the Free Software
  19.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  20.  
  21.  
  22. #ifndef alloca
  23. #ifdef __GNUC__
  24. #define alloca __builtin_alloca
  25. #else /* not GNU C.  */
  26. #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__)
  27. #include <alloca.h>
  28. #else /* not sparc */
  29. #if defined (MSDOS) && !defined (__TURBOC__)
  30. #include <malloc.h>
  31. #else /* not MSDOS, or __TURBOC__ */
  32. #if defined(_AIX)
  33. #include <malloc.h>
  34.  #pragma alloca
  35. #endif /* not _AIX */
  36. #endif /* not MSDOS, or __TURBOC__ */
  37. #endif /* not sparc.  */
  38. #endif /* not GNU C.  */
  39. #endif /* alloca not defined.  */
  40.  
  41. /* This is the parser code that is written into each bison parser
  42.   when the %semantic_parser declaration is not specified in the grammar.
  43.   It was written by Richard Stallman by simplifying the hairy parser
  44.   used when %semantic_parser is specified.  */
  45.  
  46. /* Note: there must be only one dollar sign in this file.
  47.    It is replaced by the list of actions, each action
  48.    as one case of the switch.  */
  49.  
  50. #define yyerrok        (yyerrstatus = 0)
  51. #define yyclearin    (yychar = YYEMPTY)
  52. #define YYEMPTY        -2
  53. #define YYEOF        0
  54. #define YYACCEPT    return(0)
  55. #define YYABORT     return(1)
  56. #define YYERROR        goto yyerrlab1
  57. /* Like YYERROR except do call yyerror.
  58.    This remains here temporarily to ease the
  59.    transition to the new meaning of YYERROR, for GCC.
  60.    Once GCC version 2 has supplanted version 1, this can go.  */
  61. #define YYFAIL        goto yyerrlab
  62. #define YYRECOVERING()  (!!yyerrstatus)
  63. #define YYBACKUP(token, value) \
  64. do                                \
  65.   if (yychar == YYEMPTY && yylen == 1)                \
  66.     { yychar = (token), yylval = (value);            \
  67.       yychar1 = YYTRANSLATE (yychar);                \
  68.       YYPOPSTACK;                        \
  69.       goto yybackup;                        \
  70.     }                                \
  71.   else                                \
  72.     { yyerror ("syntax error: cannot back up"); YYERROR; }    \
  73. while (0)
  74.  
  75. #define YYTERROR    1
  76. #define YYERRCODE    256
  77.  
  78. #ifndef YYPURE
  79. #define YYLEX        yylex()
  80. #endif
  81.  
  82. #ifdef YYPURE
  83. #ifdef YYLSP_NEEDED
  84. #define YYLEX        yylex(&yylval, &yylloc)
  85. #else
  86. #define YYLEX        yylex(&yylval)
  87. #endif
  88. #endif
  89.  
  90. /* If nonreentrant, generate the variables here */
  91.  
  92. #ifndef YYPURE
  93.  
  94. int    yychar;            /*  the lookahead symbol        */
  95. YYSTYPE    yylval;            /*  the semantic value of the        */
  96.                 /*  lookahead symbol            */
  97.  
  98. #ifdef YYLSP_NEEDED
  99. YYLTYPE yylloc;            /*  location data for the lookahead    */
  100.                 /*  symbol                */
  101. #endif
  102.  
  103. int yynerrs;            /*  number of parse errors so far       */
  104. #endif  /* not YYPURE */
  105.  
  106. #if YYDEBUG != 0
  107. int yydebug;            /*  nonzero means print parse trace    */
  108. /* Since this is uninitialized, it does not stop multiple parsers
  109.    from coexisting.  */
  110. #endif
  111.  
  112. /*  YYINITDEPTH indicates the initial size of the parser's stacks    */
  113.  
  114. #ifndef    YYINITDEPTH
  115. #define YYINITDEPTH 200
  116. #endif
  117.  
  118. /*  YYMAXDEPTH is the maximum size the stacks can grow to
  119.     (effective only if the built-in stack extension method is used).  */
  120.  
  121. #if YYMAXDEPTH == 0
  122. #undef YYMAXDEPTH
  123. #endif
  124.  
  125. #ifndef YYMAXDEPTH
  126. #define YYMAXDEPTH 10000
  127. #endif
  128.  
  129. #if __GNUC__ > 1        /* GNU C and GNU C++ define this.  */
  130. #define __yy_bcopy(FROM,TO,COUNT)    __builtin_memcpy(TO,FROM,COUNT)
  131. #else                /* not GNU C or C++ */
  132. #ifndef __cplusplus
  133.  
  134. /* This is the most reliable way to avoid incompatibilities
  135.    in available built-in functions on various systems.  */
  136. static void
  137. __yy_bcopy (from, to, count)
  138.      char *from;
  139.      char *to;
  140.      int count;
  141. {
  142.   register char *f = from;
  143.   register char *t = to;
  144.   register int i = count;
  145.  
  146.   while (i-- > 0)
  147.     *t++ = *f++;
  148. }
  149.  
  150. #else /* __cplusplus */
  151.  
  152. /* This is the most reliable way to avoid incompatibilities
  153.    in available built-in functions on various systems.  */
  154. static void
  155. __yy_bcopy (char *from, char *to, int count)
  156. {
  157.   register char *f = from;
  158.   register char *t = to;
  159.   register int i = count;
  160.  
  161.   while (i-- > 0)
  162.     *t++ = *f++;
  163. }
  164.  
  165. #endif
  166. #endif
  167.  
  168. #line 169 "bison.simple"
  169. int
  170. yyparse()
  171. {
  172.   register int yystate;
  173.   register int yyn;
  174.   register short *yyssp;
  175.   register YYSTYPE *yyvsp;
  176.   int yyerrstatus;    /*  number of tokens to shift before error messages enabled */
  177.   int yychar1;        /*  lookahead token as an internal (translated) token number */
  178.  
  179.   short    yyssa[YYINITDEPTH];    /*  the state stack            */
  180.   YYSTYPE yyvsa[YYINITDEPTH];    /*  the semantic value stack        */
  181.  
  182.   short *yyss = yyssa;        /*  refer to the stacks thru separate pointers */
  183.   YYSTYPE *yyvs = yyvsa;    /*  to allow yyoverflow to reallocate them elsewhere */
  184.  
  185. #ifdef YYLSP_NEEDED
  186.   YYLTYPE yylsa[YYINITDEPTH];    /*  the location stack            */
  187.   YYLTYPE *yyls = yylsa;
  188.   YYLTYPE *yylsp;
  189.  
  190. #define YYPOPSTACK   (yyvsp--, yysp--, yylsp--)
  191. #else
  192. #define YYPOPSTACK   (yyvsp--, yysp--)
  193. #endif
  194.  
  195.   int yystacksize = YYINITDEPTH;
  196.  
  197. #ifdef YYPURE
  198.   int yychar;
  199.   YYSTYPE yylval;
  200.   int yynerrs;
  201. #ifdef YYLSP_NEEDED
  202.   YYLTYPE yylloc;
  203. #endif
  204. #endif
  205.  
  206.   YYSTYPE yyval;        /*  the variable used to return        */
  207.                 /*  semantic values from the action    */
  208.                 /*  routines                */
  209.  
  210.   int yylen;
  211.  
  212. #if YYDEBUG != 0
  213.   if (yydebug)
  214.     fprintf(stderr, "Starting parse\n");
  215. #endif
  216.  
  217.   yystate = 0;
  218.   yyerrstatus = 0;
  219.   yynerrs = 0;
  220.   yychar = YYEMPTY;        /* Cause a token to be read.  */
  221.  
  222.   /* Initialize stack pointers.
  223.      Waste one element of value and location stack
  224.      so that they stay on the same level as the state stack.  */
  225.  
  226.   yyssp = yyss - 1;
  227.   yyvsp = yyvs;
  228. #ifdef YYLSP_NEEDED
  229.   yylsp = yyls;
  230. #endif
  231.  
  232. /* Push a new state, which is found in  yystate  .  */
  233. /* In all cases, when you get here, the value and location stacks
  234.    have just been pushed. so pushing a state here evens the stacks.  */
  235. yynewstate:
  236.  
  237.   *++yyssp = yystate;
  238.  
  239.   if (yyssp >= yyss + yystacksize - 1)
  240.     {
  241.       /* Give user a chance to reallocate the stack */
  242.       /* Use copies of these so that the &'s don't force the real ones into memory. */
  243.       YYSTYPE *yyvs1 = yyvs;
  244.       short *yyss1 = yyss;
  245. #ifdef YYLSP_NEEDED
  246.       YYLTYPE *yyls1 = yyls;
  247. #endif
  248.  
  249.       /* Get the current used size of the three stacks, in elements.  */
  250.       int size = yyssp - yyss + 1;
  251.  
  252. #ifdef yyoverflow
  253.       /* Each stack pointer address is followed by the size of
  254.      the data in use in that stack, in bytes.  */
  255.       yyoverflow("parser stack overflow",
  256.          &yyss1, size * sizeof (*yyssp),
  257.          &yyvs1, size * sizeof (*yyvsp),
  258. #ifdef YYLSP_NEEDED
  259.          &yyls1, size * sizeof (*yylsp),
  260. #endif
  261.          &yystacksize);
  262.  
  263.       yyss = yyss1; yyvs = yyvs1;
  264. #ifdef YYLSP_NEEDED
  265.       yyls = yyls1;
  266. #endif
  267. #else /* no yyoverflow */
  268.       /* Extend the stack our own way.  */
  269.       if (yystacksize >= YYMAXDEPTH)
  270.     {
  271.       yyerror("parser stack overflow");
  272.       return 2;
  273.     }
  274.       yystacksize *= 2;
  275.       if (yystacksize > YYMAXDEPTH)
  276.     yystacksize = YYMAXDEPTH;
  277.       yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
  278.       __yy_bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
  279.       yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
  280.       __yy_bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
  281. #ifdef YYLSP_NEEDED
  282.       yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
  283.       __yy_bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
  284. #endif
  285. #endif /* no yyoverflow */
  286.  
  287.       yyssp = yyss + size - 1;
  288.       yyvsp = yyvs + size - 1;
  289. #ifdef YYLSP_NEEDED
  290.       yylsp = yyls + size - 1;
  291. #endif
  292.  
  293. #if YYDEBUG != 0
  294.       if (yydebug)
  295.     fprintf(stderr, "Stack size increased to %d\n", yystacksize);
  296. #endif
  297.  
  298.       if (yyssp >= yyss + yystacksize - 1)
  299.     YYABORT;
  300.     }
  301.  
  302. #if YYDEBUG != 0
  303.   if (yydebug)
  304.     fprintf(stderr, "Entering state %d\n", yystate);
  305. #endif
  306.  
  307.  yybackup:
  308.  
  309. /* Do appropriate processing given the current state.  */
  310. /* Read a lookahead token if we need one and don't already have one.  */
  311. /* yyresume: */
  312.  
  313.   /* First try to decide what to do without reference to lookahead token.  */
  314.  
  315.   yyn = yypact[yystate];
  316.   if (yyn == YYFLAG)
  317.     goto yydefault;
  318.  
  319.   /* Not known => get a lookahead token if don't already have one.  */
  320.  
  321.   /* yychar is either YYEMPTY or YYEOF
  322.      or a valid token in external form.  */
  323.  
  324.   if (yychar == YYEMPTY)
  325.     {
  326. #if YYDEBUG != 0
  327.       if (yydebug)
  328.     fprintf(stderr, "Reading a token: ");
  329. #endif
  330.       yychar = YYLEX;
  331.     }
  332.  
  333.   /* Convert token to internal form (in yychar1) for indexing tables with */
  334.  
  335.   if (yychar <= 0)        /* This means end of input. */
  336.     {
  337.       yychar1 = 0;
  338.       yychar = YYEOF;        /* Don't call YYLEX any more */
  339.  
  340. #if YYDEBUG != 0
  341.       if (yydebug)
  342.     fprintf(stderr, "Now at end of input.\n");
  343. #endif
  344.     }
  345.   else
  346.     {
  347.       yychar1 = YYTRANSLATE(yychar);
  348.  
  349. #if YYDEBUG != 0
  350.       if (yydebug)
  351.     {
  352.       fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
  353.       /* Give the individual parser a way to print the precise meaning
  354.          of a token, for further debugging info.  */
  355. #ifdef YYPRINT
  356.       YYPRINT (stderr, yychar, yylval);
  357. #endif
  358.       fprintf (stderr, ")\n");
  359.     }
  360. #endif
  361.     }
  362.  
  363.   yyn += yychar1;
  364.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
  365.     goto yydefault;
  366.  
  367.   yyn = yytable[yyn];
  368.  
  369.   /* yyn is what to do for this token type in this state.
  370.      Negative => reduce, -yyn is rule number.
  371.      Positive => shift, yyn is new state.
  372.        New state is final state => don't bother to shift,
  373.        just return success.
  374.      0, or most negative number => error.  */
  375.  
  376.   if (yyn < 0)
  377.     {
  378.       if (yyn == YYFLAG)
  379.     goto yyerrlab;
  380.       yyn = -yyn;
  381.       goto yyreduce;
  382.     }
  383.   else if (yyn == 0)
  384.     goto yyerrlab;
  385.  
  386.   if (yyn == YYFINAL)
  387.     YYACCEPT;
  388.  
  389.   /* Shift the lookahead token.  */
  390.  
  391. #if YYDEBUG != 0
  392.   if (yydebug)
  393.     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
  394. #endif
  395.  
  396.   /* Discard the token being shifted unless it is eof.  */
  397.   if (yychar != YYEOF)
  398.     yychar = YYEMPTY;
  399.  
  400.   *++yyvsp = yylval;
  401. #ifdef YYLSP_NEEDED
  402.   *++yylsp = yylloc;
  403. #endif
  404.  
  405.   /* count tokens shifted since error; after three, turn off error status.  */
  406.   if (yyerrstatus) yyerrstatus--;
  407.  
  408.   yystate = yyn;
  409.   goto yynewstate;
  410.  
  411. /* Do the default action for the current state.  */
  412. yydefault:
  413.  
  414.   yyn = yydefact[yystate];
  415.   if (yyn == 0)
  416.     goto yyerrlab;
  417.  
  418. /* Do a reduction.  yyn is the number of a rule to reduce with.  */
  419. yyreduce:
  420.   yylen = yyr2[yyn];
  421.   yyval = yyvsp[1-yylen]; /* implement default value of the action */
  422.  
  423. #if YYDEBUG != 0
  424.   if (yydebug)
  425.     {
  426.       int i;
  427.  
  428.       fprintf (stderr, "Reducing via rule %d (line %d), ",
  429.            yyn, yyrline[yyn]);
  430.  
  431.       /* Print the symboles being reduced, and their result.  */
  432.       for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
  433.     fprintf (stderr, "%s ", yytname[yyrhs[i]]);
  434.       fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
  435.     }
  436. #endif
  437.  
  438. $   /* the action file gets copied in in place of this dollarsign */
  439. #line 440 "bison.simple"
  440.  
  441.   yyvsp -= yylen;
  442.   yyssp -= yylen;
  443. #ifdef YYLSP_NEEDED
  444.   yylsp -= yylen;
  445. #endif
  446.  
  447. #if YYDEBUG != 0
  448.   if (yydebug)
  449.     {
  450.       short *ssp1 = yyss - 1;
  451.       fprintf (stderr, "state stack now");
  452.       while (ssp1 != yyssp)
  453.     fprintf (stderr, " %d", *++ssp1);
  454.       fprintf (stderr, "\n");
  455.     }
  456. #endif
  457.  
  458.   *++yyvsp = yyval;
  459.  
  460. #ifdef YYLSP_NEEDED
  461.   yylsp++;
  462.   if (yylen == 0)
  463.     {
  464.       yylsp->first_line = yylloc.first_line;
  465.       yylsp->first_column = yylloc.first_column;
  466.       yylsp->last_line = (yylsp-1)->last_line;
  467.       yylsp->last_column = (yylsp-1)->last_column;
  468.       yylsp->text = 0;
  469.     }
  470.   else
  471.     {
  472.       yylsp->last_line = (yylsp+yylen-1)->last_line;
  473.       yylsp->last_column = (yylsp+yylen-1)->last_column;
  474.     }
  475. #endif
  476.  
  477.   /* Now "shift" the result of the reduction.
  478.      Determine what state that goes to,
  479.      based on the state we popped back to
  480.      and the rule number reduced by.  */
  481.  
  482.   yyn = yyr1[yyn];
  483.  
  484.   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
  485.   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
  486.     yystate = yytable[yystate];
  487.   else
  488.     yystate = yydefgoto[yyn - YYNTBASE];
  489.  
  490.   goto yynewstate;
  491.  
  492. yyerrlab:   /* here on detecting error */
  493.  
  494.   if (! yyerrstatus)
  495.     /* If not already recovering from an error, report this error.  */
  496.     {
  497.       ++yynerrs;
  498.  
  499. #ifdef YYERROR_VERBOSE
  500.       yyn = yypact[yystate];
  501.  
  502.       if (yyn > YYFLAG && yyn < YYLAST)
  503.     {
  504.       int size = 0;
  505.       char *msg;
  506.       int x, count;
  507.  
  508.       count = 0;
  509.       for (x = 0; x < (sizeof(yytname) / sizeof(char *)); x++)
  510.         if (yycheck[x + yyn] == x)
  511.           size += strlen(yytname[x]) + 15, count++;
  512.       msg = (char *) xmalloc(size + 15);
  513.       strcpy(msg, "parse error");
  514.  
  515.       if (count < 5)
  516.         {
  517.           count = 0;
  518.           for (x = 0; x < (sizeof(yytname) / sizeof(char *)); x++)
  519.         if (yycheck[x + yyn] == x)
  520.           {
  521.             strcat(msg, count == 0 ? ", expecting `" : " or `");
  522.             strcat(msg, yytname[x]);
  523.             strcat(msg, "'");
  524.             count++;
  525.           }
  526.         }
  527.       yyerror(msg);
  528.       free(msg);
  529.     }
  530.       else
  531. #endif /* YYERROR_VERBOSE */
  532.     yyerror("parse error");
  533.     }
  534.  
  535. yyerrlab1:   /* here on error raised explicitly by an action */
  536.  
  537.   if (yyerrstatus == 3)
  538.     {
  539.       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
  540.  
  541.       /* return failure if at end of input */
  542.       if (yychar == YYEOF)
  543.     YYABORT;
  544.  
  545. #if YYDEBUG != 0
  546.       if (yydebug)
  547.     fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
  548. #endif
  549.  
  550.       yychar = YYEMPTY;
  551.     }
  552.  
  553.   /* Else will try to reuse lookahead token
  554.      after shifting the error token.  */
  555.  
  556.   yyerrstatus = 3;        /* Each real token shifted decrements this */
  557.  
  558.   goto yyerrhandle;
  559.  
  560. yyerrdefault:  /* current state does not do anything special for the error token. */
  561.  
  562. #if 0
  563.   /* This is wrong; only states that explicitly want error tokens
  564.      should shift them.  */
  565.   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
  566.   if (yyn) goto yydefault;
  567. #endif
  568.  
  569. yyerrpop:   /* pop the current state because it cannot handle the error token */
  570.  
  571.   if (yyssp == yyss) YYABORT;
  572.   yyvsp--;
  573.   yystate = *--yyssp;
  574. #ifdef YYLSP_NEEDED
  575.   yylsp--;
  576. #endif
  577.  
  578. #if YYDEBUG != 0
  579.   if (yydebug)
  580.     {
  581.       short *ssp1 = yyss - 1;
  582.       fprintf (stderr, "Error: state stack now");
  583.       while (ssp1 != yyssp)
  584.     fprintf (stderr, " %d", *++ssp1);
  585.       fprintf (stderr, "\n");
  586.     }
  587. #endif
  588.  
  589. yyerrhandle:
  590.  
  591.   yyn = yypact[yystate];
  592.   if (yyn == YYFLAG)
  593.     goto yyerrdefault;
  594.  
  595.   yyn += YYTERROR;
  596.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
  597.     goto yyerrdefault;
  598.  
  599.   yyn = yytable[yyn];
  600.   if (yyn < 0)
  601.     {
  602.       if (yyn == YYFLAG)
  603.     goto yyerrpop;
  604.       yyn = -yyn;
  605.       goto yyreduce;
  606.     }
  607.   else if (yyn == 0)
  608.     goto yyerrpop;
  609.  
  610.   if (yyn == YYFINAL)
  611.     YYACCEPT;
  612.  
  613. #if YYDEBUG != 0
  614.   if (yydebug)
  615.     fprintf(stderr, "Shifting error token, ");
  616. #endif
  617.  
  618.   *++yyvsp = yylval;
  619. #ifdef YYLSP_NEEDED
  620.   *++yylsp = yylloc;
  621. #endif
  622.  
  623.   yystate = yyn;
  624.   goto yynewstate;
  625. }
  626.